package com.lanou3g.farmdoctor.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lanou3g.farmdoctor.R;
import com.lanou3g.farmdoctor.adapter.ForRichPagerAdapter;
import com.lanou3g.farmdoctor.base.BaseFragment;

/**
 * 本类由: Risky 创建于: 15/11/24.
 * 致富经界面
 */
public class ForRichExpFragment extends BaseFragment {

    private TabLayout tabLayout;
    private ViewPager viewPager;
    private TextView tvMiddle;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_rich,container,false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view);
    }

    private void initView(View view) {
        tvMiddle = (TextView) view.findViewById(R.id.tv_middle);
        tabLayout = (TabLayout) view.findViewById(R.id.tabLayout);
        tabLayout.setSelectedTabIndicatorColor(0xff33ff33);
        viewPager = (ViewPager) view.findViewById(R.id.viewPager);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        tvMiddle.setText(R.string.for_rich);
        // 配置ViewPager适配器,并与TabLayout绑定
        ForRichPagerAdapter adapter = new ForRichPagerAdapter(getChildFragmentManager());
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
    }
}

